class Solution {
public:
    bool validPalindrome(string s) {
        int left = 0, right = s.size() - 1;
        while (left < right)
        {
            if (s[left] == s[right])
            {
                left++;
                right--;
            }
            else
            {
                return _validPalindrome(s, left + 1, right) || _validPalindrome(s, left, right - 1);
            }
        }
        return true;
    }
    bool _validPalindrome(string s, int left, int right)
    {
        while (left < right)
        {
            if (s[left] != s[right]) return false;
            left++, right--;
        }
        return true;
    }
};
class Solution {
public:
    int mySqrt(int x) {
        long long left = 0, right = x;
        while (left < right)
        {
            long long mid = left + (right - left + 1) / 2;
            if (mid * mid <= x) {
                left = mid;
            }
            else {
                right = mid - 1;
            }
        }
        return left;
    }
};